package com.banmoon.datastructure.RedBlackTree;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class BRTreeTest {

    BRTree<Integer, Integer> tree;

    @Before
    public void before() {
        tree = new BRTree<>(10, 10);
        tree.add(0, 0);
        tree.add(20, 20);
//        String sb = tree.middleShow();
//        Assert.assertEquals("0 10 20 ", sb);
    }

    @Test
    public void leftLeft() {
        tree.add(-10, -10);
        String sb = tree.middleShow();
        Assert.assertEquals("-10 0 10 20 ", sb);
    }

    @Test
    public void leftRight() {
        tree.add(5, 5);
        String sb = tree.middleShow();
        Assert.assertEquals("0 5 10 20 ", sb);
    }

    @Test
    public void rightRight() {
        tree.add(30, 30);
        String sb = tree.middleShow();
        Assert.assertEquals("0 10 20 30 ", sb);
    }

    @Test
    public void rightLeft() {
        tree.add(15, 15);
        String sb = tree.middleShow();
        Assert.assertEquals("0 10 15 20 ", sb);
    }

    @Test
    public void recursive() {
        tree.add(-20, -20);
        tree.add(-30, -30);
//        tree.add(50, 50);
        String sb = tree.middleShow();
        System.out.println(sb);
    }

}
